package com.example.qihuibao.module.setting

import android.os.Bundle
import com.example.qihuibao.base.BaseActivity
import com.example.qihuibao.bean.DeviceBean
import com.example.qihuibao.constant.Config
import com.example.qihuibao.databinding.ActivitySettingBinding
import com.example.qihuibao.utils.ConnectUtil
import com.example.qihuibao.utils.extension.toast

class SettingActivity : BaseActivity<ActivitySettingBinding>(ActivitySettingBinding::inflate) {
    private val deviceBeans = mutableListOf<DeviceBean>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewBinding.titleBar.setTitle("设置")
        viewBinding.switchServer.isChecked = Config.isServerStation
        viewBinding.switchServer.setOnCheckedChangeListener { buttonView, isChecked ->
            Config.isServerStation = isChecked
            configServerStation()
        }
        //
//        viewBinding.ivRefresh.visibility = if (Config.isServerStation) View.VISIBLE else View.GONE
        viewBinding.ivRefresh.setOnClickListener {
            Thread {
                if (Config.isServerStation) {
                    ConnectUtil.groupSend()
                }/*else {
                    ConnectUtil.clientGroup({
                        runOnUiThread { toast(it) }
                    },{
                        runOnUiThread { toast(it) }
                    })
                }*/
            }.start()
        }
        //
//        viewBinding.recyclerView.init(
//            R.layout.item_client,
//            LinearLayoutManager(this, RecyclerView.VERTICAL, false),
//            clients,
//            { view, pos ->
//                view.findViewById<TextView>(R.id.tv_name).text = clients[pos].sn
//                view.findViewById<TextView>(R.id.tv_ip).text = clients[pos].ip
//                view.findViewById<TextView>(R.id.tv_connect).text = clients[pos].connect
//            }
//        )
    }

}